package com.jjy.dao.impl;

import com.jjy.dao.OrderDao;
import com.jjy.pojo.Order;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public class OrderDaoImpl implements OrderDao{
    private SqlSessionFactory sqlSessionFactory;

    public OrderDaoImpl(SqlSessionFactory sqlSessionFactory) {
        this.sqlSessionFactory = sqlSessionFactory;
    }

    @Override
    public Order getOrderById(int id) {
        return null;
    }

    @Override
    public List<Order> getOrderByNo(int number) {
        return null;
    }

    @Override
    public List<Order> getAllOrder() {
        SqlSession sqlSession = sqlSessionFactory.openSession();
        return sqlSession.selectList("getAllOrder");
    }

    @Override
    public List<Order> getOrderByParams(Order order) {
        return null;
    }

    @Override
    public int createOrder(Order order) {
        SqlSession sqlSession = sqlSessionFactory.openSession();
        return sqlSession.insert("createOrder" , order);
    }

    @Override
    public int updateOrder(Order order) {
        return 0;
    }

    @Override
    public Long getMaxOrderNo() {
        SqlSession sqlSession = sqlSessionFactory.openSession();
        return sqlSession.selectOne("getMaxOrderNo");
    }
}
